Skip to content

Avoid disconnect on message timeout while waiting on monitor/signer #3721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Apr 8, 2025

When sending/receiving commitment_signed/revoke_and_ack, we may expect the counterparty to follow up with one of their own in response. In some cases, they are not allowed to send it because they are actually waiting for one from us. Async monitor updates and signing requests may result in the message we need to send to the counterparty being delayed, and our disconnect logic previously did not consider that. It doesn't make sense to disconnect our counterparty when we're the ones seemingly blocking progress.

This commit ensures we no longer disconnect when we're waiting on an async monitor update or signing request, unless we're negotiating quiescence. Note that while our counterparty is still able to enforce a similar disconnect logic on their side, as they have no insight into why we're not able to make progress, this commit at least helps prevent reconnection cycles with those that don't enforce one.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Apr 8, 2025

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@wpaulino wpaulino requested a review from TheBlueMatt April 8, 2025 21:37
Copy link

codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 98.65772% with 2 lines in your changes missing coverage. Please review.

Project coverage is 89.11%. Comparing base (c4d23bc) to head (ede5154).
Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/async_signer_tests.rs 98.13% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3721      +/-   ##
==========================================
+ Coverage   89.05%   89.11%   +0.06%     
==========================================
  Files         155      156       +1     
  Lines      122019   123699    +1680     
  Branches   122019   123699    +1680     
==========================================
+ Hits       108666   110240    +1574     
- Misses      10695    10778      +83     
- Partials     2658     2681      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpaulino wpaulino force-pushed the no-disconnect-async-monitor-signer branch from 2f7a61b to d8c8195 Compare April 10, 2025 19:27
Copy link
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% confident as I am not yet up to speed on quiescence and async signers / monitor updates.

I went through another round of manual mutation testing and things looking good.

Just that one last live mutant I found - but maybe we leave this for a followup.

/// been sent by either side but not yet irrevocably committed on both commitments because we're
/// waiting on a pending monitor update or signer request.
pub fn is_monitor_or_signer_pending_channel_update(&self) -> bool {
self.monitor_pending_revoke_and_ack || self.signer_pending_revoke_and_ack
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: replacing self.monitor_pending_revoke_and_ack with false passes the test suite, but happy to address this myself in a follow-up as practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, feel free to follow-up. I don't think the coverage is too critical here to hold this back.

@wpaulino wpaulino force-pushed the no-disconnect-async-monitor-signer branch from d8c8195 to 49dd8d3 Compare April 15, 2025 19:03
@wpaulino wpaulino requested a review from TheBlueMatt April 15, 2025 19:04
When sending/receiving `commitment_signed`/`revoke_and_ack`, we may
expect the counterparty to follow up with one of their own in response.
In some cases, they are not allowed to send it because they are actually
waiting for one from us. Async monitor updates and signing requests may
result in the message we need to send to the counterparty being delayed,
and our disconnect logic previously did not consider that. It doesn't
make sense to disconnect our counterparty when we're the ones seemingly
blocking progress.

This commit ensures we no longer disconnect when we're waiting on an
async monitor update or signing request, unless we're negotiating
quiescence. Note that while our counterparty is still able to enforce a
similar disconnect logic on their side, as they have no insight into why
we're not able to make progress, this commit at least helps prevent
reconnection cycles with those that don't enforce one.
@wpaulino wpaulino force-pushed the no-disconnect-async-monitor-signer branch from 49dd8d3 to ede5154 Compare April 16, 2025 18:35
@wpaulino wpaulino requested a review from TheBlueMatt April 16, 2025 18:51
@TheBlueMatt TheBlueMatt merged commit 22d4b42 into lightningdevkit:main Apr 16, 2025
26 of 27 checks passed
@wpaulino wpaulino deleted the no-disconnect-async-monitor-signer branch April 17, 2025 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants